/*
 * @Author: HZK
 * @Date: 2020-09-17 14:12:22
 * @LastEditTime: 2020-12-01 13:24:13
 * @LastEditors: hanfengmi
 * @Description: base
 */
const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
	module: {
		rules: [
      {
        test: /\.(js|jsx)$/,
        use: "babel-loader",
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|jpeg|gif)$/,
        use: [
            {
                loader: 'url-loader',
                options:{
                    name:'[path][name].[ext]',
                    esModule: false,  //避免 <img src=[Module Object] />
                    limit: 1024 * 10,
                    fallback: 'file-loader',
                }
            },
        ],
      },
    ]
  },
  plugins:[
    new HtmlWebpackPlugin({
        filename: "index.html",
        template: "./public/index.html",
        minify: {
        collapseWhitespace: true // 压缩
        }
    }),
  ],
  resolve:{
    extensions: ['.js', '.jsx', '.scss', '.less', '.css', '.json'],
    alias: {
        '@': path.resolve('./src'),
        '@assets': path.resolve('./public/assets')
    }
  }
};
